$(document).ready(function(){
	var userPhone = localStorage.getItem('keyName');
	if(userPhone){
	    $('#userPhone').val(userPhone);
    }
});
function login() {
	/*$("#userPwd").val(hex_md5($("#password").val()));
	var data = formToJson($("#user-login"));*/
	var userPhone = $("#userPhone").val();
	var userPwd =  hex_md5($("#password").val()); 
	
    if($('#rmbuser').is(':checked')){
        localStorage.setItem('keyName',userPhone);
    }else{
        localStorage.removeItem('keyName');
    }
	
	$.ajax({
		url : url + '/ic-iot/users/authorization',//117
		type : 'post',
		dataType : 'json',
		async:false, 
		data :{
			"userPhone":userPhone,
			"userPwd":userPwd,
			
			"platformTag":'1',
		},
		success : function(data) {
			if(data['code']!=1){
				layer.msg(data['description']);
			}else{
				var storage=window.localStorage;
				storage.setItem("time",data.result.lastActiveTime);
	            storage.setItem("adminId",data.result.id);
	            storage.setItem("accessToken",data.result.accessToken);
	            storage.setItem("userType",data.result.userType);
				window.location.href = 'index.html';
			}
		},
		error: function(data) { 
			layer.msg("连接失败，后台维护中");
		} 
	});
}
function KeyDown(){
  if (event.keyCode == 13){
    event.returnValue=false;
    event.cancel = true;
    Form1.btnsubmit.click();
    $("#userPwd").val(hex_md5($("#password").val()));
  //debugger;
  }
}

